home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / ppc-amigaos / include / sys / signal.h < prev    next >
C/C++ Source or Header  |  1996-12-11  |  8KB  |  232 lines

  1. /*    $NetBSD: signal.h,v 1.19 1995/08/13 22:51:24 mycroft Exp $    */
  2.  
  3. /*
  4.  * Copyright (c) 1982, 1986, 1989, 1991, 1993
  5.  *    The Regents of the University of California.  All rights reserved.
  6.  * (c) UNIX System Laboratories, Inc.
  7.  * All or some portions of this file are derived from material licensed
  8.  * to the University of California by American Telephone and Telegraph
  9.  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  10.  * the permission of UNIX System Laboratories, Inc.
  11.  *
  12.  * Redistribution and use in source and binary forms, with or without
  13.  * modification, are permitted provided that the following conditions
  14.  * are met:
  15.  * 1. Redistributions of source code must retain the above copyright
  16.  *    notice, this list of conditions and the following disclaimer.
  17.  * 2. Redistributions in binary form must reproduce the above copyright
  18.  *    notice, this list of conditions and the following disclaimer in the
  19.  *    documentation and/or other materials provided with the distribution.
  20.  * 3. All advertising materials mentioning features or use of this software
  21.  *    must display the following acknowledgement:
  22.  *    This product includes software developed by the University of
  23.  *    California, Berkeley and its contributors.
  24.  * 4. Neither the name of the University nor the names of its contributors
  25.  *    may be used to endorse or promote products derived from this software
  26.  *    without specific prior written permission.
  27.  *
  28.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  29.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  32.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  37.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38.  * SUCH DAMAGE.
  39.  *
  40.  *    @(#)signal.h    8.2 (Berkeley) 1/21/94
  41.  */
  42.  
  43. #ifndef    _SYS_SIGNAL_H_
  44. #define    _SYS_SIGNAL_H_
  45.  
  46. #include <machine/signal.h>    /* sigcontext; codes for SIGILL, SIGFPE */
  47.  
  48. #define _NSIG    33    /* counting 0; could be 33 (mask is 1-32) */
  49.  
  50. #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  51. #define NSIG _NSIG
  52. #endif
  53.  
  54. #define    SIGHUP    1    /* hangup */
  55. #define    SIGINT    2    /* interrupt */
  56. #define    SIGQUIT    3    /* quit */
  57. #define    SIGILL    4    /* illegal instruction (not reset when caught) */
  58. #ifndef _POSIX_SOURCE
  59. #define    SIGTRAP    5    /* trace trap (not reset when caught) */
  60. #endif
  61. #define    SIGABRT    6    /* abort() */
  62. #ifndef _POSIX_SOURCE
  63. #define    SIGIOT    SIGABRT    /* compatibility */
  64. #define    SIGEMT    7    /* EMT instruction */
  65. #endif
  66. #define    SIGFPE    8    /* floating point exception */
  67. #define    SIGKILL    9    /* kill (cannot be caught or ignored) */
  68. #ifndef _POSIX_SOURCE
  69. #define    SIGBUS    10    /* bus error */
  70. #endif
  71. #define    SIGSEGV    11    /* segmentation violation */
  72. #ifndef _POSIX_SOURCE
  73. #define    SIGSYS    12    /* bad argument to system call */
  74. #endif
  75. #define    SIGPIPE    13    /* write on a pipe with no one to read it */
  76. #define    SIGALRM    14    /* alarm clock */
  77. #define    SIGTERM    15    /* software termination signal from kill */
  78. #ifndef _POSIX_SOURCE
  79. #define    SIGURG    16    /* urgent condition on IO channel */
  80. #endif
  81. #define    SIGSTOP    17    /* sendable stop signal not from tty */
  82. #define    SIGTSTP    18    /* stop signal from tty */
  83. #define    SIGCONT    19    /* continue a stopped process */
  84. #define    SIGCHLD    20    /* to parent on child stop or exit */
  85. #define    SIGTTIN    21    /* to readers pgrp upon background tty read */
  86. #define    SIGTTOU    22    /* like TTIN for output if (tp->t_local<OSTOP) */
  87. #ifndef _POSIX_SOURCE
  88. #define    SIGIO    23    /* input/output possible signal */
  89. #define    SIGXCPU    24    /* exceeded CPU time limit */
  90. #define    SIGXFSZ    25    /* exceeded file size limit */
  91. #define    SIGVTALRM 26    /* virtual time alarm */
  92. #define    SIGPROF    27    /* profiling time alarm */
  93. #define SIGWINCH 28    /* window size changes */
  94. #define SIGINFO    29    /* information request */
  95. #endif
  96. #define SIGUSR1 30    /* user defined signal 1 */
  97. #define SIGUSR2 31    /* user defined signal 2 */
  98. #define SIGMSG    32    /* an AmigaOS signal has been set. SIGMSG is normally ignored.
  99.                (code is the mask of new signals) */
  100.  
  101. #if defined(_ANSI_SOURCE) || defined(__cplusplus)
  102. /*
  103.  * Language spec sez we must list exactly one parameter, even though we
  104.  * actually supply three.  Ugh!
  105.  */
  106. #define    SIG_DFL        (void (*)(int))0
  107. #define    SIG_IGN        (void (*)(int))1
  108. #define    SIG_ERR        (void (*)(int))-1
  109. #else
  110. #define    SIG_DFL        (void (*)())0
  111. #define    SIG_IGN        (void (*)())1
  112. #define    SIG_ERR        (void (*)())-1
  113. #endif
  114.  
  115. #ifndef _ANSI_SOURCE
  116. typedef unsigned int sigset_t;
  117.  
  118. /*
  119.  * Signal vector "template" used in sigaction call.
  120.  */
  121. struct    sigaction {
  122.     void    (*sa_handler)();    /* signal handler */
  123.     sigset_t sa_mask;        /* signal mask to apply */
  124.     int    sa_flags;        /* see signal options below */
  125. };
  126. #ifndef _POSIX_SOURCE
  127. #define SA_ONSTACK    0x0001    /* take signal on signal stack */
  128. #define SA_RESTART    0x0002    /* restart system on signal return */
  129. #define SA_RESETHAND    0x0004    /* reset to SIG_DFL when taking signal */
  130. #define SA_NODEFER    0x0010    /* don't mask the signal we're delivering */
  131. #ifdef COMPAT_SUNOS
  132. #define    SA_USERTRAMP    0x0100    /* do not bounce off kernel's sigtramp */
  133. #endif
  134. #endif
  135. #define SA_NOCLDSTOP    0x0008    /* do not generate SIGCHLD on child stop */
  136.  
  137. /*
  138.  * Flags for sigprocmask:
  139.  */
  140. #define    SIG_BLOCK    1    /* block specified signal set */
  141. #define    SIG_UNBLOCK    2    /* unblock specified signal set */
  142. #define    SIG_SETMASK    3    /* set specified signal set */
  143.  
  144. #ifndef _POSIX_SOURCE
  145. #ifndef _KERNEL
  146. #include <sys/cdefs.h>
  147. #endif
  148. typedef    void (*sig_t) __P((int));    /* type of signal function */
  149.  
  150. /*
  151.  * Structure used in sigaltstack call.
  152.  */
  153. struct    sigaltstack {
  154.     char    *ss_base;        /* signal stack base */
  155.     int    ss_size;        /* signal stack length */
  156.     int    ss_flags;        /* SS_DISABLE and/or SS_ONSTACK */
  157. };
  158. #define SS_ONSTACK    0x0001    /* take signals on alternate stack */
  159. #define SS_DISABLE    0x0004    /* disable taking signals on alternate stack */
  160. #define    MINSIGSTKSZ    8192            /* minimum allowable stack */
  161. #define    SIGSTKSZ    (MINSIGSTKSZ + 32768)    /* recommended stack size */
  162.  
  163. /*
  164.  * 4.3 compatibility:
  165.  * Signal vector "template" used in sigvec call.
  166.  */
  167. struct    sigvec {
  168.     void    (*sv_handler)();    /* signal handler */
  169.     int    sv_mask;        /* signal mask to apply */
  170.     int    sv_flags;        /* see signal options below */
  171. };
  172. #define SV_ONSTACK    SA_ONSTACK
  173. #define SV_INTERRUPT    SA_RESTART    /* same bit, opposite sense */
  174. #define SV_RESETHAND    SA_RESETHAND
  175. #define sv_onstack sv_flags    /* isn't compatibility wonderful! */
  176.  
  177. /*
  178.  * Structure used in sigstack call.
  179.  */
  180. struct    sigstack {
  181.     char    *ss_sp;            /* signal stack pointer */
  182.     int    ss_onstack;        /* current status */
  183. };
  184.  
  185. /*
  186.  * Macro for converting signal number to a mask suitable for
  187.  * sigblock().
  188.  */
  189. #define sigmask(m)    (1 << ((m)-1))
  190.  
  191. #define    BADSIG        SIG_ERR
  192.  
  193. #endif    /* !_POSIX_SOURCE */
  194. #endif    /* !_ANSI_SOURCE */
  195.  
  196. #ifdef _KERNEL
  197.  
  198. #define    SIG_CATCH    (void (*)())2
  199. #define    SIG_HOLD    (void (*)())3
  200.  
  201. #define    sigcantmask    (sigmask(SIGKILL)|sigmask(SIGSTOP))
  202. /*
  203.  * get signal action for process and signal; currently only for current process
  204.  */
  205. #define SIGACTION(p, sig)    (u.u_signal[(sig)])
  206.  
  207. /*
  208.  * Determine signal that should be delivered to process p, the current process,
  209.  * 0 if none.  If there is a pending stop signal with default action,
  210.  * the process stops in issig().
  211.  */
  212. #define    CURSIG(p) \
  213.     (((p)->p_sig == 0 || \
  214.         (((p)->p_flag&STRC) == 0 && ((p)->p_sig &~ (p)->p_sigmask) == 0)) ? \
  215.         0 : issig(p))
  216.  
  217. /*
  218.  * Clear a pending signal from a process.
  219.  */
  220. #define    CLRSIG(p, sig)    { (p)->p_sig &= ~sigmask(sig); }
  221.  
  222. #endif
  223.  
  224. /*
  225.  * For historical reasons; programs expect signal's return value to be
  226.  * defined by <sys/signal.h>.
  227.  */
  228. __BEGIN_DECLS
  229. void    (*signal __P((int, void (*) __P((int))))) __P((int));
  230. __END_DECLS
  231. #endif    /* !_SYS_SIGNAL_H_ */
  232.